'use strict'

class user {
    
  constructor (db) {
    this.db = db
    this.tableName = 'user_list'
  }

  /*
   * cond = {
   *   age : {
   *     '>' : 12,
   *     '<' : 18
   *   },
   *   role : 'user',
   *   is_delete : 0
   * }
   *
   *
   *
   *
   * */

  async get (cond) {

    let u = await this.db.model(this.tableName).where(cond).select()

    if (u.rowCount <= 0) {
      return null
    }

    return u.rows[0]
  }

  async list (cond, pagesize = 20, offset = 0) {

    let ulist = await this.db.model(this.tableName).where(cond).limit(pagesize, offset).select()

    return ulist.rows
  }



}

module.exports = user

